﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;
using YJKArchUtils.Utils;
using YJKRevitStairs.StairsModel.CommonUnit;
using YJKRevitStairs.StairsModel.DataInfos;
using YJKRevitStairs.StairsModel.Kit;

namespace YJKRevitStairs.StairsModel.Form
{
	public partial class EscalatorForm : EscBaseForm
	{
		public EscalatorForm(ExternalCommandData cmdData)
		{
			this.m_Revit = cmdData;
			this.m_StairsDrawingKit = new EscalatorKit(this.m_Revit.Application.Application);
			this.InitializeComponent();
			this.m_MainPreviewer = new Previewer(this, this.pnlPreview.Left, this.pnlPreview.Top, this.pnlPreview.Width, this.pnlPreview.Height, 1u);
			this.pnlPreview.Visible = false;
			base.MouseWheel += this.m_MainPreviewer.MouseWheel;
		}

		protected override void DefWndProc(ref Message m)
		{
			int msg = m.Msg;
			if (msg == 1125)
			{
				if (m.WParam.ToInt32() != 1)
				{
					return;
				}
				List<CurveInfo> curves = new List<CurveInfo>();
				List<TextNoteInfo> textNotes = new List<TextNoteInfo>();
				try
				{
					this.GetProfileCurves(ref curves, ref textNotes);
					this.m_MainPreviewer.Curves = curves;
					this.m_MainPreviewer.TextNotes = textNotes;
					return;
				}
				catch (Exception)
				{
					return;
				}
			}
			base.DefWndProc(ref m);
		}

		private List<CurveInfo> TransFormCurves(List<CurveInfo> sourceCurves, int nIndexTag, List<Escalator.TransformTag> arTags)
		{
			List<CurveInfo> list = new List<CurveInfo>();
			list.AddRange(sourceCurves);
			if (arTags.Count > nIndexTag)
			{
				Escalator.TransformTag transformTag = arTags[nIndexTag];
				if (transformTag.m_bTurn)
				{
					Transform matrix = Transform.CreateRotationAtPoint(XYZ.BasisZ, Math.PI, transformTag.m_ptCenter);
					for (int i = 0; i < list.Count; i++)
					{
						list[i] = list[i].LineTransformTo(matrix);
					}
				}
			}
			return list;
		}

		private void GetProfileCurves(ref List<CurveInfo> curvesInfoList, ref List<TextNoteInfo> textNoteInfoList)
		{
			Escalator escalator = new Escalator();
			escalator.m_FloorType = this.GetFloorType();
			escalator.m_dStairsWidth = YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.StairsWidth);
			escalator.m_LeftRunData = this.GetRunData();
			escalator.m_MidOneRunData = this.GetRunData();
			escalator.m_MidTwoRunData = this.GetRunData();
			escalator.m_RightRunData = this.GetRunData();
			escalator.m_UpStairsType = this.GetUpstairs();
			escalator.m_nRunCount = this.GetRunCount();
			escalator.m_dStairsDis = this.GetStairsDis();
			escalator.m_bNoteUpStairs = this.GetNoteInfo();
			escalator.m_dFrontDepth = this.GetStairsFrontDepth();
			escalator.m_dStartDepth = this.GetStairsStartDepth();
			escalator.m_dTreadDepth = this.GetStairsTreadDepth();
			escalator.m_nIndexInsertPos = this.GetInsertIndex();
			escalator.m_PlaceType = this.GetPlaceType();
			this.m_StairsDrawingKit.EscalatorProfileCurves(ref escalator, this.chkNoteInfo.Checked, true, this.chkLRMirror.Checked, this.chkTBMirror.Checked, this.RotateAngle);
			foreach (SingleRunCurveInfo singleRunCurveInfo in escalator.m_listRunCurve)
			{
				curvesInfoList.AddRange(singleRunCurveInfo.RunBoundaryCurvesInfoList);
				curvesInfoList.AddRange(singleRunCurveInfo.RunRiserCurvesInfoList);
				curvesInfoList.AddRange(singleRunCurveInfo.RunPathCurvesInfoList);
			}
			curvesInfoList.AddRange(escalator.m_listOtherCurve);
			textNoteInfoList = escalator.m_listText;
		}

		private void CalcRunLength()
		{
			if (this.m_bCalc && 0.0 < this.InclineAngle && this.hyTbHeight.Enabled)
			{
				double num = 1.0 / Math.Tan(this.InclineAngle);
				this.RunLength = num * this.StairsHeight;
			}
		}

		private void CalcStairsDis()
		{
			if (this.m_bCalc)
			{
				int runCount = this.RunCount;
			}
		}

		private void CalcHSpan()
		{
			if (this.m_bCalc && 0.0 < this.InclineAngle && this.hyTbHSpan.Enabled)
			{
				double hspan = this.RunLength + this.StairsFrontDepth + this.StairsStartDepth + 2.0 * this.StairsTreadDepth;
				this.HSpan = hspan;
			}
		}

		public double CalculateMinPitWidth()
		{
			double stairsWidth = this.StairsWidth;
			int runCount = this.RunCount;
			double stairsDis = this.StairsDis;
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet((stairsWidth - stairsDis * (double)(runCount - 1)) / (double)runCount);
		}

		private void CalcStairsWidth()
		{
			if (this.m_bCalc)
			{
				this.StairsWidth = this.RunWidth * (double)this.RunCount + this.StairsDis * (double)(this.RunCount - 1);
				string familyName = this.GetFamilyName();
				if (familyName.Equals(this.m_sAuto))
				{
					this.StairsWidth += this.m_dAuto * 2.0 * (double)this.RunCount;
					return;
				}
				if (familyName.Equals(this.m_s0))
				{
					this.StairsWidth += this.m_d0 * 2.0 * (double)this.RunCount;
					return;
				}
				if (familyName.Equals(this.m_s1To4))
				{
					this.StairsWidth += this.m_d1To4 * 2.0 * (double)this.RunCount;
					return;
				}
				if (familyName.Equals(this.m_s10To12))
				{
					this.StairsWidth += this.m_d10To12 * 2.0 * (double)this.RunCount;
				}
			}
		}

		private void CalcRunWidth()
		{
		}

		private bool IsTextValueValid(string sText)
		{
			return !sText.Contains("--");
		}

		private double TextToValidDouble(string sText)
		{
			double result = 0.0;
			if (string.IsNullOrEmpty(sText) || string.IsNullOrWhiteSpace(sText))
			{
				return result;
			}
			double.TryParse(sText, out result);
			return result;
		}

		public double GuardHeight
		{
			get
			{
				string text = this.hyTbGuardHeight.Text;
				return this.TextToValidDouble(text);
			}
			set
			{
				this.hyTbGuardHeight.Text = value.ToString("f0");
			}
		}

		public double RotateAngle
		{
			get
			{
				return this.StrToDouble(this.hyTbRotateAngle.Text) / 180.0 * Math.PI;
			}
			set
			{
				this.hyTbRotateAngle.Text = (value * 180.0 / Math.PI).ToString("f2");
			}
		}

		public double InclineAngle
		{
			get
			{
				return this.StrToDouble(this.cmbInclineAngle.Text) / 180.0 * Math.PI;
			}
			set
			{
				this.cmbInclineAngle.Text = (value * 180.0 / Math.PI).ToString("f1");
			}
		}

		public double RunWidth
		{
			get
			{
				string text = this.hyTbRunWidth.Text;
				return this.TextToValidDouble(text);
			}
			set
			{
				this.hyTbRunWidth.Text = value.ToString("f0");
			}
		}

		public int RunCount
		{
			get
			{
				string text = this.cmbRunCount.Text;
				return this.StrToInt(text);
			}
		}

		public double StairsWidth
		{
			get
			{
				string text = this.hyTbStairsWidth.Text;
				return this.TextToValidDouble(text);
			}
			set
			{
				this.hyTbStairsWidth.Text = value.ToString("f0");
			}
		}

		public double StairsHeight
		{
			get
			{
				string text = this.hyTbHeight.Text;
				return this.TextToValidDouble(text);
			}
			set
			{
				this.hyTbHeight.Text = value.ToString("f0");
			}
		}

		public double StairsOffset
		{
			get
			{
				string text = this.hyTbPosOffset.Text;
				return this.TextToValidDouble(text);
			}
			set
			{
				this.hyTbPosOffset.Text = value.ToString("f0");
			}
		}

		public double TreadHeight
		{
			get
			{
				return 180.0;
			}
		}

		public double TreadDepth
		{
			get
			{
				string text = this.hyTbRunDepth.Text;
				double result = this.TextToValidDouble(text);
				if (this.chkAsRamp.Checked)
				{
					result = this.RunLength;
				}
				return result;
			}
		}

		public double RunLength
		{
			get
			{
				string text = this.hyTbRunLength.Text;
				return this.TextToValidDouble(text);
			}
			set
			{
				this.hyTbRunLength.Text = value.ToString("f0");
			}
		}

		public double HSpan
		{
			get
			{
				string text = this.hyTbHSpan.Text;
				return this.TextToValidDouble(text);
			}
			set
			{
				this.hyTbHSpan.Text = value.ToString("f0");
			}
		}

		public double StairsDis
		{
			get
			{
				string text = this.hyTbStairsDistance.Text;
				return this.TextToValidDouble(text);
			}
			set
			{
				this.hyTbStairsDistance.Text = value.ToString("f0");
			}
		}

		public double StairsFrontDepth
		{
			get
			{
				string text = this.hyTbFrontDepth.Text;
				return this.TextToValidDouble(text);
			}
		}

		public double StairsTreadDepth
		{
			get
			{
				string text = this.hyTbTreadDepth.Text;
				return this.TextToValidDouble(text);
			}
		}

		public double StairsStartDepth
		{
			get
			{
				string text = this.hyTbStartDepth.Text;
				return this.TextToValidDouble(text);
			}
		}

		public double TopPitExturn
		{
			get
			{
				string text = this.hyTbUpPitExturn.Text;
				return this.TextToValidDouble(text);
			}
			set
			{
				this.hyTbUpPitExturn.Text = value.ToString("f0");
			}
		}

		public double TopPitLength
		{
			get
			{
				string text = this.hyTbUpPitLength.Text;
				return this.TextToValidDouble(text);
			}
			set
			{
				this.hyTbUpPitLength.Text = value.ToString("f0");
			}
		}

		public double TopPitDepth
		{
			get
			{
				string text = this.hyTbUpPitDepth.Text;
				return this.TextToValidDouble(text);
			}
			set
			{
				this.hyTbUpPitDepth.Text = value.ToString("f0");
			}
		}

		public double BtmPitExturn
		{
			get
			{
				string text = this.hyTbDownPitExturn.Text;
				return this.TextToValidDouble(text);
			}
			set
			{
				this.hyTbDownPitExturn.Text = value.ToString("f0");
			}
		}

		public double BtmPitLength
		{
			get
			{
				string text = this.hyTbDownPitLength.Text;
				return this.TextToValidDouble(text);
			}
			set
			{
				this.hyTbDownPitLength.Text = value.ToString("f0");
			}
		}

		public double BtmPitDepth
		{
			get
			{
				string text = this.hyTbDownPitDepth.Text;
				return this.TextToValidDouble(text);
			}
			set
			{
				this.hyTbDownPitDepth.Text = value.ToString("f0");
			}
		}

		public EscalatorForm.MeasureType theMeasureType
		{
			get
			{
				return this.m_MeasureType;
			}
		}

		public int NumSerial
		{
			get
			{
				return YJKRevitStairs.StairsModel.CommonUnit.Common.StrToInt(this.hyTbNumSerial.Text, 0);
			}
			set
			{
				this.hyTbNumSerial.Text = value.ToString();
			}
		}

		public string NumPreFix
		{
			get
			{
				return this.hyTbNumPreFix.Text;
			}
			set
			{
				this.hyTbNumPreFix.Text = value;
			}
		}

		public string NumSubFix
		{
			get
			{
				return this.hyTbSubFix.Text;
			}
			set
			{
				this.hyTbSubFix.Text = value;
			}
		}

		public YJKRevitStairs.StairsModel.DataInfos.FloorType GetFloorType()
		{
			if (this.rbFirstFloor.Checked)
			{
				return YJKRevitStairs.StairsModel.DataInfos.FloorType.FT_Bottom;
			}
			if (this.rbMiddleFloor.Checked)
			{
				return YJKRevitStairs.StairsModel.DataInfos.FloorType.FT_Mid;
			}
			return YJKRevitStairs.StairsModel.DataInfos.FloorType.FT_Top;
		}

		public UpStairsType GetUpstairs()
		{
			if (this.rbUpStairsLeft.Checked)
			{
				return UpStairsType.UST_Left;
			}
			if (this.rbUpStairsMid.Checked)
			{
				return UpStairsType.UST_Mid;
			}
			return UpStairsType.UST_Right;
		}

		public Escalator.PlaceType GetPlaceType()
		{
			Escalator.PlaceType result = Escalator.PlaceType.PT_ParallelSameDirect;
			if (this.rbparallelSameDirect.Checked)
			{
				result = Escalator.PlaceType.PT_ParallelSameDirect;
			}
			else if (this.rbParallelReverseDirect.Checked)
			{
				result = Escalator.PlaceType.PT_ParallelReverseDirect;
			}
			else if (this.rbCrossSameDirect.Checked)
			{
				result = Escalator.PlaceType.PT_CrossingSameDirect;
			}
			else if (this.rbCrossReverseDirect.Checked)
			{
				result = Escalator.PlaceType.PT_CrossingReverseDirect;
			}
			return result;
		}

		public double GetStairsHeight()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.StairsHeight);
		}

		public double GetStairsOffset()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.StairsOffset);
		}

		public double GetStairsWidth()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.StairsWidth);
		}

		public double GetRunWidth()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.RunWidth);
		}

		public double GetRunLength()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.RunLength);
		}

		public double GetRunDepth()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.TreadDepth);
		}

		public LineRunData GetRunData()
		{
			LineRunData lineRunData = new LineRunData();
			lineRunData.RunWidth = YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.RunWidth);
			lineRunData.TreadHeight = YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.TreadHeight);
			lineRunData.TreadDepth = YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.TreadDepth);
			lineRunData.TreadCount = (int)(this.RunLength / this.TreadDepth);
			lineRunData.RunLength = lineRunData.TreadDepth * (double)lineRunData.TreadCount;
			lineRunData.RunHeight = lineRunData.TreadHeight * (double)(lineRunData.TreadCount + 1);
			lineRunData.BottomElevation = 0.0;
			return lineRunData;
		}

		public int GetRunCount()
		{
			return this.StrToInt(this.cmbRunCount.Text);
		}

		public int GetInsertIndex()
		{
			return this.m_BasePointIndex;
		}

		public bool GetNoteInfo()
		{
			return this.chkNoteInfo.Checked;
		}

		public bool GetIsRamp()
		{
			return this.chkAsRamp.Checked;
		}

		public bool GetTBMirror()
		{
			return this.chkTBMirror.Checked;
		}

		public bool GetLRMirror()
		{
			return this.chkLRMirror.Checked;
		}

		public double GetStairsDis()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.StairsDis);
		}

		public double GetStairsFrontDepth()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.StairsFrontDepth);
		}

		public double GetStairsTreadDepth()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.StairsTreadDepth);
		}

		public double GetStairsStartDepth()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.StairsStartDepth);
		}

		public double GetStairsHSpan()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.HSpan);
		}

		public double GetGuardHeight()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.GuardHeight);
		}

		public double GetTopPitLength()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.TopPitLength);
		}

		public double GetTopPitDepth()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.TopPitDepth);
		}

		public double GetTopPitExturn()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.TopPitExturn);
		}

		public double GetBtmPitLength()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.BtmPitLength);
		}

		public double GetBtmPitDepth()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.BtmPitDepth);
		}

		public double GetBtmPitExturn()
		{
			return YJKRevitStairs.StairsModel.CommonUnit.Common.MMToFeet(this.BtmPitExturn);
		}

		public string GetRevitVeision()
		{
			return this.m_Revit.Application.Application.VersionNumber;
		}

		public Escalator.PosInsertType GetStairsInsertType()
		{
			Escalator.PosInsertType result;
			switch (this.m_BasePointIndex)
			{
			case 0:
				result = Escalator.PosInsertType.PIT_LftBtm;
				if (this.chkTBMirror.Checked && !this.chkLRMirror.Checked)
				{
					result = Escalator.PosInsertType.PIT_LftTop;
				}
				else if (!this.chkTBMirror.Checked && this.chkLRMirror.Checked)
				{
					result = Escalator.PosInsertType.PIT_RhtBtm;
				}
				else if (this.chkTBMirror.Checked && this.chkLRMirror.Checked)
				{
					result = Escalator.PosInsertType.PIT_RhtTop;
				}
				break;
			case 1:
				result = Escalator.PosInsertType.PIT_LftTop;
				if (this.chkTBMirror.Checked && !this.chkLRMirror.Checked)
				{
					result = Escalator.PosInsertType.PIT_LftBtm;
				}
				else if (!this.chkTBMirror.Checked && this.chkLRMirror.Checked)
				{
					result = Escalator.PosInsertType.PIT_RhtTop;
				}
				else if (this.chkTBMirror.Checked && this.chkLRMirror.Checked)
				{
					result = Escalator.PosInsertType.PIT_RhtBtm;
				}
				break;
			case 2:
				result = Escalator.PosInsertType.PIT_RhtTop;
				if (this.chkTBMirror.Checked && !this.chkLRMirror.Checked)
				{
					result = Escalator.PosInsertType.PIT_RhtBtm;
				}
				else if (!this.chkTBMirror.Checked && this.chkLRMirror.Checked)
				{
					result = Escalator.PosInsertType.PIT_LftTop;
				}
				else if (this.chkTBMirror.Checked && this.chkLRMirror.Checked)
				{
					result = Escalator.PosInsertType.PIT_LftBtm;
				}
				break;
			case 3:
				result = Escalator.PosInsertType.PIT_RhtBtm;
				if (this.chkTBMirror.Checked && !this.chkLRMirror.Checked)
				{
					result = Escalator.PosInsertType.PIT_RhtTop;
				}
				else if (!this.chkTBMirror.Checked && this.chkLRMirror.Checked)
				{
					result = Escalator.PosInsertType.PIT_LftBtm;
				}
				else if (this.chkTBMirror.Checked && this.chkLRMirror.Checked)
				{
					result = Escalator.PosInsertType.PIT_LftTop;
				}
				break;
			default:
				result = Escalator.PosInsertType.PIT_LftBtm;
				break;
			}
			return result;
		}

		public string GetFamilyName()
		{
			string result = this.m_sAuto;
			double num = this.StrToDouble(this.cmbInclineAngle.Text);
			if (this.chkAsRamp.Checked)
			{
				if (Math.Abs(num - 0.0) < 1E-07)
				{
					result = this.m_s0;
				}
				else if (num > 0.0 && num < 4.1)
				{
					result = this.m_s1To4;
				}
				else
				{
					result = this.m_s10To12;
				}
			}
			return result;
		}

		public string GetFamilySymbolName()
		{
			string result = "玻璃挡板";
			if (this.rbGold.Checked)
			{
				result = "金属挡板";
			}
			return result;
		}

		private int StrToInt(string str)
		{
			int result = 0;
			int num;
			if (int.TryParse(str, out num))
			{
				result = num;
			}
			return result;
		}

		private double StrToDouble(string str)
		{
			double result = 0.0;
			double num;
			if (double.TryParse(str, out num))
			{
				result = num;
			}
			return result;
		}

		private bool StrToBoolean(string str)
		{
			bool result = false;
			bool flag;
			if (bool.TryParse(str, out flag))
			{
				result = flag;
			}
			return result;
		}

		private void SetContrlsText(List<System.Windows.Forms.Control> arCtrls, ref StreamReader sReader)
		{
			foreach (System.Windows.Forms.Control control in arCtrls)
			{
				string text = sReader.ReadLine();
				if (text.Contains("--"))
				{
					control.Text = text;
				}
				else
				{
					control.Text = this.StrToInt(text).ToString();
				}
				this.SetTextBoxTag(control);
			}
		}

		private void SaveContrlsText(List<System.Windows.Forms.Control> arCtrls, ref StreamWriter sWriter)
		{
			foreach (System.Windows.Forms.Control control in arCtrls)
			{
				sWriter.WriteLine(control.Text);
			}
		}

		private void SetTextBoxTag(System.Windows.Forms.Control ctrl)
		{
			ctrl.Tag = ctrl.Text;
		}

		private void SetDefaultData()
		{
			this.hyTbHeight.Text = "4500";
			this.SetTextBoxTag(this.hyTbHeight);
			this.hyTbPosOffset.Text = "0";
			this.SetTextBoxTag(this.hyTbPosOffset);
			this.hyTbRunWidth.Text = "1000";
			this.SetTextBoxTag(this.hyTbRunWidth);
			this.hyTbStairsWidth.Text = "1800";
			this.SetTextBoxTag(this.hyTbStairsWidth);
			this.hyTbRunLength.Text = "8000";
			this.SetTextBoxTag(this.hyTbRunLength);
			this.hyTbHSpan.Text = "15300";
			this.SetTextBoxTag(this.hyTbHSpan);
			this.hyTbRunDepth.Text = "380";
			this.SetTextBoxTag(this.hyTbRunDepth);
			this.cmbRunCount.Text = "1";
			this.hyTbFrontDepth.Text = "600";
			this.SetTextBoxTag(this.hyTbFrontDepth);
			this.hyTbStartDepth.Text = "1800";
			this.SetTextBoxTag(this.hyTbStartDepth);
			this.hyTbTreadDepth.Text = "800";
			this.SetTextBoxTag(this.hyTbTreadDepth);
			this.hyTbStairsDistance.Text = "200";
			this.SetTextBoxTag(this.hyTbStairsDistance);
			this.cmbInclineAngle.Text = "30";
			this.SetTextBoxTag(this.cmbInclineAngle);
			this.rbGlass.Checked = true;
			this.rbGold.Checked = false;
			this.hyTbGuardHeight.Text = "1000";
			this.SetTextBoxTag(this.hyTbGuardHeight);
			this.hyTbUpPitLength.Text = "1000";
			this.SetTextBoxTag(this.hyTbUpPitLength);
			this.hyTbUpPitExturn.Text = "150";
			this.SetTextBoxTag(this.hyTbUpPitExturn);
			this.hyTbUpPitDepth.Text = "1100";
			this.SetTextBoxTag(this.hyTbUpPitDepth);
			this.hyTbDownPitLength.Text = "1000";
			this.SetTextBoxTag(this.hyTbDownPitLength);
			this.hyTbDownPitExturn.Text = "180";
			this.SetTextBoxTag(this.hyTbDownPitExturn);
			this.hyTbDownPitDepth.Text = "1200";
			this.SetTextBoxTag(this.hyTbDownPitDepth);
			this.rbUpStairsLeft.Checked = true;
			this.rbUpStairsMid.Checked = false;
			this.rbUpStairsRight.Checked = false;
			this.rbFirstFloor.Checked = true;
			this.rbMiddleFloor.Checked = false;
			this.rbparallelSameDirect.Checked = true;
			this.rbParallelReverseDirect.Checked = false;
			this.rbCrossSameDirect.Checked = false;
			this.rbCrossReverseDirect.Checked = false;
			this.hyTbRotateAngle.Text = "0";
			this.SetTextBoxTag(this.hyTbRotateAngle);
			this.chkAsRamp.Checked = false;
			this.chkTBMirror.Checked = false;
			this.chkLRMirror.Checked = false;
			this.chkNoteInfo.Checked = true;
			this.hyTbNumPreFix.Text = "FT";
			this.hyTbNumSerial.Text = "1";
			this.hyTbSubFix.Text = "";
		}

		private List<System.Windows.Forms.Control> CreateTextControlsList()
		{
			return new List<System.Windows.Forms.Control>
			{
				this.hyTbHeight,
				this.hyTbPosOffset,
				this.hyTbRunWidth,
				this.hyTbStairsWidth,
				this.hyTbRunLength,
				this.hyTbHSpan,
				this.hyTbRunDepth,
				this.cmbRunCount,
				this.hyTbFrontDepth,
				this.hyTbStartDepth,
				this.hyTbTreadDepth,
				this.hyTbStairsDistance
			};
		}

		private void ReadFloorType(int nType)
		{
			switch (nType)
			{
			case 0:
				this.rbFirstFloor.Checked = true;
				this.rbMiddleFloor.Checked = false;
				return;
			case 1:
				this.rbFirstFloor.Checked = false;
				this.rbMiddleFloor.Checked = true;
				return;
			case 2:
				this.rbFirstFloor.Checked = false;
				this.rbMiddleFloor.Checked = false;
				return;
			default:
				this.rbFirstFloor.Checked = true;
				this.rbMiddleFloor.Checked = false;
				return;
			}
		}

		private void ReadPlaceStyle(int nPlaceStyle)
		{
			switch (nPlaceStyle)
			{
			case 0:
				this.rbparallelSameDirect.Checked = true;
				this.rbParallelReverseDirect.Checked = false;
				this.rbCrossSameDirect.Checked = false;
				this.rbCrossReverseDirect.Checked = false;
				return;
			case 1:
				this.rbparallelSameDirect.Checked = false;
				this.rbParallelReverseDirect.Checked = true;
				this.rbCrossSameDirect.Checked = false;
				this.rbCrossReverseDirect.Checked = false;
				return;
			case 2:
				this.rbparallelSameDirect.Checked = false;
				this.rbParallelReverseDirect.Checked = false;
				this.rbCrossSameDirect.Checked = true;
				this.rbCrossReverseDirect.Checked = false;
				return;
			case 3:
				this.rbparallelSameDirect.Checked = false;
				this.rbParallelReverseDirect.Checked = false;
				this.rbCrossSameDirect.Checked = false;
				this.rbCrossReverseDirect.Checked = true;
				return;
			default:
				this.rbparallelSameDirect.Checked = true;
				this.rbParallelReverseDirect.Checked = false;
				this.rbCrossSameDirect.Checked = false;
				this.rbCrossReverseDirect.Checked = false;
				return;
			}
		}

		private void ReadData()
		{
			string path = Path.GetTempPath() + "EscalatorForm.dat";
			if (!File.Exists(path))
			{
				this.SetDefaultData();
				return;
			}
			FileStream fileStream = new FileStream(path, FileMode.Open);
			StreamReader streamReader = new StreamReader(fileStream);
			streamReader.BaseStream.Seek(0L, SeekOrigin.Begin);
			this.SetContrlsText(this.CreateTextControlsList(), ref streamReader);
			this.cmbInclineAngle.Text = streamReader.ReadLine();
			this.SetTextBoxTag(this.cmbInclineAngle);
			this.rbGlass.Checked = this.StrToBoolean(streamReader.ReadLine());
			this.rbGold.Checked = this.StrToBoolean(streamReader.ReadLine());
			this.hyTbGuardHeight.Text = this.StrToInt(streamReader.ReadLine()).ToString();
			this.SetTextBoxTag(this.hyTbGuardHeight);
			this.hyTbUpPitLength.Text = this.StrToInt(streamReader.ReadLine()).ToString();
			this.SetTextBoxTag(this.hyTbUpPitLength);
			this.hyTbUpPitExturn.Text = this.StrToInt(streamReader.ReadLine()).ToString();
			this.SetTextBoxTag(this.hyTbUpPitExturn);
			this.hyTbUpPitDepth.Text = this.StrToInt(streamReader.ReadLine()).ToString();
			this.SetTextBoxTag(this.hyTbUpPitDepth);
			this.hyTbDownPitLength.Text = this.StrToInt(streamReader.ReadLine()).ToString();
			this.SetTextBoxTag(this.hyTbDownPitLength);
			this.hyTbDownPitExturn.Text = this.StrToInt(streamReader.ReadLine()).ToString();
			this.SetTextBoxTag(this.hyTbDownPitExturn);
			this.hyTbDownPitDepth.Text = this.StrToInt(streamReader.ReadLine()).ToString();
			this.SetTextBoxTag(this.hyTbDownPitDepth);
			this.rbUpStairsLeft.Checked = this.StrToBoolean(streamReader.ReadLine());
			this.rbUpStairsMid.Checked = this.StrToBoolean(streamReader.ReadLine());
			this.rbUpStairsRight.Checked = this.StrToBoolean(streamReader.ReadLine());
			int nType = this.StrToInt(streamReader.ReadLine());
			this.ReadFloorType(nType);
			int nPlaceStyle = this.StrToInt(streamReader.ReadLine());
			this.ReadPlaceStyle(nPlaceStyle);
			this.hyTbRotateAngle.Text = this.StrToDouble(streamReader.ReadLine()).ToString("f2");
			this.SetTextBoxTag(this.hyTbRotateAngle);
			this.m_BasePointIndex = this.StrToInt(streamReader.ReadLine());
			this.chkAsRamp.Checked = this.StrToBoolean(streamReader.ReadLine());
			this.chkTBMirror.Checked = this.StrToBoolean(streamReader.ReadLine());
			this.chkLRMirror.Checked = this.StrToBoolean(streamReader.ReadLine());
			this.chkNoteInfo.Checked = this.StrToBoolean(streamReader.ReadLine());
			this.hyTbNumPreFix.Text = streamReader.ReadLine();
			this.hyTbNumSerial.Text = YJKRevitStairs.StairsModel.CommonUnit.Common.StrToInt(streamReader.ReadLine(), 0).ToString();
			this.hyTbSubFix.Text = streamReader.ReadLine();
			streamReader.Close();
			fileStream.Close();
		}

		public void SaveData()
		{
			FileStream fileStream = new FileStream(Path.GetTempPath() + "EscalatorForm.dat", FileMode.Create);
			StreamWriter streamWriter = new StreamWriter(fileStream);
			this.SaveContrlsText(this.CreateTextControlsList(), ref streamWriter);
			streamWriter.WriteLine(this.cmbInclineAngle.Text);
			streamWriter.WriteLine(this.rbGlass.Checked);
			streamWriter.WriteLine(this.rbGold.Checked);
			streamWriter.WriteLine(this.hyTbGuardHeight.Text);
			streamWriter.WriteLine(this.hyTbUpPitLength.Text);
			streamWriter.WriteLine(this.hyTbUpPitExturn.Text);
			streamWriter.WriteLine(this.hyTbUpPitDepth.Text);
			streamWriter.WriteLine(this.hyTbDownPitLength.Text);
			streamWriter.WriteLine(this.hyTbDownPitExturn.Text);
			streamWriter.WriteLine(this.hyTbDownPitDepth.Text);
			streamWriter.WriteLine(this.rbUpStairsLeft.Checked);
			streamWriter.WriteLine(this.rbUpStairsMid.Checked);
			streamWriter.WriteLine(this.rbUpStairsRight.Checked);
			if (this.rbFirstFloor.Checked)
			{
				streamWriter.WriteLine(0);
			}
			else if (this.rbMiddleFloor.Checked)
			{
				streamWriter.WriteLine(1);
			}
			else
			{
				streamWriter.WriteLine(2);
			}
			if (this.rbparallelSameDirect.Checked)
			{
				streamWriter.WriteLine(0);
			}
			else if (this.rbParallelReverseDirect.Checked)
			{
				streamWriter.WriteLine(1);
			}
			else if (this.rbCrossSameDirect.Checked)
			{
				streamWriter.WriteLine(2);
			}
			else
			{
				streamWriter.WriteLine(3);
			}
			streamWriter.WriteLine(this.hyTbRotateAngle.Text);
			streamWriter.WriteLine(this.m_BasePointIndex);
			streamWriter.WriteLine(this.chkAsRamp.Checked);
			streamWriter.WriteLine(this.chkTBMirror.Checked);
			streamWriter.WriteLine(this.chkLRMirror.Checked);
			streamWriter.WriteLine(this.chkNoteInfo.Checked);
			streamWriter.WriteLine(this.hyTbNumPreFix.Text);
			streamWriter.WriteLine(this.hyTbNumSerial.Text);
			streamWriter.WriteLine(this.hyTbSubFix.Text);
			streamWriter.Flush();
			streamWriter.Close();
			fileStream.Close();
		}

		private void SetInclineAngleComboValues(bool bIsRamp)
		{
			string text = this.cmbInclineAngle.Text;
			this.cmbInclineAngle.Items.Clear();
			if (bIsRamp)
			{
				this.cmbInclineAngle.Items.Add("0");
				this.cmbInclineAngle.Items.Add("1");
				this.cmbInclineAngle.Items.Add("2");
				this.cmbInclineAngle.Items.Add("3");
				this.cmbInclineAngle.Items.Add("4");
				this.cmbInclineAngle.Items.Add("10");
				this.cmbInclineAngle.Items.Add("11");
				this.cmbInclineAngle.Items.Add("12");
			}
			else
			{
				this.cmbInclineAngle.Items.Add("27.3");
				this.cmbInclineAngle.Items.Add("30");
				this.cmbInclineAngle.Items.Add("35");
			}
			this.cmbInclineAngle.Text = text;
		}

		private void SetRunCountComboValues(int nIndex)
		{
			List<string> list = new List<string>();
			list.Add("1");
			list.Add("2");
			list.Add("3");
			list.Add("4");
			this.cmbRunCount.DataSource = list;
			this.cmbRunCount.SelectedIndex = nIndex;
		}

		private void ShowZeroCrosswalk()
		{
			if (!this.m_bCalc)
			{
				return;
			}
			if (this.chkAsRamp.Checked && 0.0 == this.InclineAngle)
			{
				this.hyTbHeight.Enabled = false;
				this.hyTbHeight.Text = "--";
				this.hyTbHSpan.Enabled = false;
				this.hyTbHSpan.Text = "--";
				this.hyTbRunDepth.Enabled = false;
				this.hyTbRunDepth.Text = "--";
				this.hyTbRunLength.ReadOnly = false;
				return;
			}
			this.hyTbHeight.Enabled = true;
			if (this.hyTbHeight.Text.Contains("--"))
			{
				string text = this.hyTbHeight.Tag as string;
				if (text == "--")
				{
					this.hyTbHeight.Text = "4500";
				}
				else
				{
					this.hyTbHeight.Text = text;
				}
			}
			this.hyTbHSpan.Enabled = true;
			this.hyTbRunDepth.Enabled = true;
			if (this.hyTbRunDepth.Text.Contains("--"))
			{
				string text2 = this.hyTbRunDepth.Tag as string;
				if (text2 == "--")
				{
					this.hyTbRunDepth.Text = "380";
				}
				else
				{
					this.hyTbRunDepth.Text = text2;
				}
			}
			this.hyTbRunLength.ReadOnly = true;
		}

		private void EscalatorForm_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
			this.SetRunCountComboValues(0);
			this.ReadData();
			this.SetInclineAngleComboValues(this.chkAsRamp.Checked);
			this.m_bCalc = true;
			this.ShowZeroCrosswalk();
		}

		private void EscalatorForm_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (DialogResult.Cancel == base.DialogResult)
			{
				return;
			}
			this.SaveData();
		}

		private void btnRunWidth_Click(object sender, EventArgs e)
		{
			this.m_MeasureType = EscalatorForm.MeasureType.MT_RunWidth;
			this.hyTbRunWidth.Focus();
		}

		private void btnStairsWidth_Click(object sender, EventArgs e)
		{
			this.m_MeasureType = EscalatorForm.MeasureType.MT_StairsWidth;
			this.hyTbStairsWidth.Focus();
		}

		private void btnRotateAngle_Click(object sender, EventArgs e)
		{
			this.m_MeasureType = EscalatorForm.MeasureType.MT_Angle;
			this.hyTbRotateAngle.Focus();
		}

		private void btnChangeInsertPoint_Click(object sender, EventArgs e)
		{
			int num = this.m_BasePointIndex + 1;
			this.m_BasePointIndex = num % 4;
			this.m_MainPreviewer.Refresh();
		}

		private void cmbInclineAngle_Validating(object sender, CancelEventArgs e)
		{
			string text = this.cmbInclineAngle.Text;
			if (text.Contains("."))
			{
				double num = 0.0;
				double.TryParse(text, out num);
				this.cmbInclineAngle.Text = num.ToString("f1");
			}
			else
			{
				int num2 = 0;
				int.TryParse(text, out num2);
				this.cmbInclineAngle.Text = num2.ToString();
			}
			if (YJKRevitStairs.StairsModel.CommonUnit.Common.StrToDouble(this.cmbInclineAngle.Text, 0.0) > 35.0)
			{
				this.cmbInclineAngle.Text = (string)this.cmbInclineAngle.Tag;
				MessageBox.Show("倾斜角度：应该 <=35度", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
			this.SetTextBoxTag(this.cmbInclineAngle);
		}

		private void hyTbRotateAngle_Validating(object sender, CancelEventArgs e)
		{
			this.hyTbRotateAngle.Text = this.StrToDouble(this.hyTbRotateAngle.Text).ToString("f2");
		}

		private void hyTbStairsWidth_Validating(object sender, CancelEventArgs e)
		{
			if (this.StairsWidth < (this.RunWidth + 100.0) * (double)this.RunCount + this.StairsDis * (double)(this.RunCount - 1))
			{
				this.hyTbStairsWidth.Text = (string)this.hyTbStairsWidth.Tag;
				MessageBox.Show("扶梯总宽应 >= (梯级宽度 + 100mm) * 梯跑数目 + 扶梯间距 *（梯跑数目 - 1)", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
			this.SetTextBoxTag(this.hyTbStairsWidth);
		}

		private void hyTbStairsDistance_Validating(object sender, CancelEventArgs e)
		{
		}

		private bool IsInvalidUpPitWidth()
		{
			return false;
		}

		private bool IsInvalidDownPitWidth()
		{
			return false;
		}

		private void hyTbUpPitWidth_Validating(object sender, CancelEventArgs e)
		{
			this.SetTextBoxTag(this.hyTbUpPitExturn);
			this.SetTextBoxTag(this.hyTbDownPitExturn);
		}

		private void hyTbDownPitWidth_Validating(object sender, CancelEventArgs e)
		{
			this.SetTextBoxTag(this.hyTbUpPitExturn);
			this.SetTextBoxTag(this.hyTbDownPitExturn);
		}

		private void hyTbRunWidth_Validating(object sender, CancelEventArgs e)
		{
			if (YJKRevitStairs.StairsModel.CommonUnit.Common.IsDoubleLessThanZero(this.RunWidth) || this.RunWidth < 600.0)
			{
				this.hyTbRunWidth.Text = (string)this.hyTbRunWidth.Tag;
				MessageBox.Show("梯级宽度应该>=600.0mm", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
			this.SetTextBoxTag(this.hyTbRunWidth);
		}

		private void hyTbRunLength_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbRunDepth_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbFrontDepth_TextChanged(object sender, EventArgs e)
		{
			this.CalcHSpan();
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbStartDepth_TextChanged(object sender, EventArgs e)
		{
			this.CalcHSpan();
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbTreadDepth_TextChanged(object sender, EventArgs e)
		{
			this.CalcHSpan();
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbStairsDistance_TextChanged(object sender, EventArgs e)
		{
			this.CalcStairsWidth();
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbHeight_TextChanged(object sender, EventArgs e)
		{
			if (this.hyTbHeight.Enabled)
			{
				this.CalcRunLength();
				this.CalcHSpan();
			}
			this.m_MainPreviewer.Refresh();
		}

		private void cmbInclineAngle_TextChanged(object sender, EventArgs e)
		{
			this.ShowZeroCrosswalk();
			this.CalcRunLength();
			this.CalcHSpan();
			this.CalcStairsWidth();
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbRunWidth_TextChanged(object sender, EventArgs e)
		{
			this.CalcStairsWidth();
			this.SetTextBoxTag(this.hyTbStairsWidth);
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbStairsWidth_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void hyTbRotateAngle_TextChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void chkAsRamp_CheckedChanged(object sender, EventArgs e)
		{
			this.SetInclineAngleComboValues(this.chkAsRamp.Checked);
			if (!this.chkAsRamp.Checked)
			{
				this.ShowZeroCrosswalk();
			}
			this.CalcStairsWidth();
		}

		private void chkNoteInfo_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void chkTBMirror_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void chkLRMirror_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void rbCrossReverseDirect_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void rbparallelSameDirect_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void rbCrossSameDirect_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void rbParallelReverseDirect_CheckedChanged(object sender, EventArgs e)
		{
			this.m_MainPreviewer.Refresh();
		}

		private void rbUpStairsLeft_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rbUpStairsLeft.Enabled)
			{
				this.m_MainPreviewer.Refresh();
			}
		}

		private void rbUpStairsMid_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rbUpStairsMid.Enabled)
			{
				this.m_MainPreviewer.Refresh();
			}
		}

		private void rbUpStairsRight_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rbUpStairsRight.Enabled)
			{
				this.m_MainPreviewer.Refresh();
			}
		}

		private void cmbInclineAngle_KeyPress(object sender, KeyPressEventArgs e)
		{
			string text = this.cmbInclineAngle.Text + e.KeyChar.ToString();
			e.Handled = (e.KeyChar < '0' || e.KeyChar > '9');
			if (e.KeyChar == '\b')
			{
				e.Handled = false;
			}
			if (e.KeyChar == '.')
			{
				if (text.Length <= 0)
				{
					e.Handled = true;
					return;
				}
				float num;
				if (float.TryParse(text, out num))
				{
					e.Handled = false;
				}
			}
		}

		private void cmbRunCount_KeyPress(object sender, KeyPressEventArgs e)
		{
		}

		private void cmbRunCount_SelectedIndexChanged(object sender, EventArgs e)
		{
			int runCount = this.GetRunCount();
			if (1 == runCount)
			{
				this.rbUpStairsLeft.Enabled = false;
				this.rbUpStairsMid.Enabled = false;
				this.rbUpStairsRight.Enabled = false;
			}
			else if (2 == runCount)
			{
				if (this.rbUpStairsMid.Checked)
				{
					this.rbUpStairsLeft.Checked = true;
				}
				this.rbUpStairsMid.Enabled = false;
				if (!this.rbUpStairsLeft.Enabled)
				{
					this.rbUpStairsLeft.Enabled = true;
				}
				if (!this.rbUpStairsRight.Enabled)
				{
					this.rbUpStairsRight.Enabled = true;
				}
			}
			else
			{
				this.rbUpStairsLeft.Enabled = true;
				this.rbUpStairsMid.Enabled = true;
				this.rbUpStairsRight.Enabled = true;
			}
			this.CalcStairsWidth();
			this.m_MainPreviewer.Refresh();
		}

		private void cmbInclineAngle_DataSourceChanged(object sender, EventArgs e)
		{
		}

		private bool ValidatingDataParam(ref string message)
		{
			bool result = true;
			string text = "";
			string text2 = "  数值规范超过13J404中，";
			string text3 = "  的限定";
			if ((this.StairsHeight < 3000.0 || this.StairsHeight > 10000.0) && this.hyTbHeight.Enabled)
			{
				text = string.Concat(new string[]
				{
					text,
					"扶梯高度:",
					text2,
					"扶梯高度>=3000mm且<=10000mm",
					text3
				});
				text += "\n";
				result = false;
			}
			if (this.TreadDepth < 380.0)
			{
				text = string.Concat(new string[]
				{
					text,
					"梯级深度:",
					text2,
					"梯级深度≥380mm",
					text3
				});
				text += "\n";
				result = false;
			}
			if (this.chkAsRamp.Checked && (this.RunWidth < 580.0 || this.RunWidth > 1100.0))
			{
				text = string.Concat(new string[]
				{
					text,
					"梯级宽度:",
					text2,
					"梯级宽度≥580mm且≤1100mm",
					text3
				});
				text += "\n";
				result = false;
			}
			if (!this.chkAsRamp.Checked)
			{
				double inclineAngle = this.InclineAngle;
				if (0.0 <= inclineAngle && inclineAngle <= 4.0)
				{
					if (this.RunWidth != 800.0 && this.RunWidth != 1000.0 && this.RunWidth != 1200.0)
					{
						text = string.Concat(new string[]
						{
							text,
							"梯级宽度:",
							text2,
							"梯级宽度应为800mm、1000mm、1200mm",
							text3
						});
						text += "\n";
						result = false;
					}
				}
				else if (10.0 <= inclineAngle && inclineAngle <= 12.0 && this.RunWidth != 800.0 && this.RunWidth != 1000.0)
				{
					text = string.Concat(new string[]
					{
						text,
						"梯级宽度:",
						text2,
						"梯级宽度应为800mm、1000mm",
						text3
					});
					text += "\n";
					result = false;
				}
			}
			if (this.BtmPitDepth <= 1100.0 || this.BtmPitDepth >= 1300.0)
			{
				text = string.Concat(new string[]
				{
					text,
					"下部梯坑深度:",
					text2,
					"下部梯坑的深度取值应>1100mm且<1300mm",
					text3
				});
				text += "\n";
				result = false;
			}
			if (this.TopPitDepth <= 1050.0 || this.TopPitDepth >= 1250.0)
			{
				text = string.Concat(new string[]
				{
					text,
					"下部梯坑深度:",
					text2,
					"上部梯坑的深度取值应>1050mm且<1250mm",
					text3
				});
				text += "\n";
				result = false;
			}
			if (this.StairsWidth < (this.RunWidth + 100.0) * (double)this.RunCount + this.StairsDis * (double)(this.RunCount - 1))
			{
				text = text + "扶梯总宽应 >= (梯级宽度 + 100mm) * 梯跑数目 + 扶梯间距 *（梯跑数目 - 1)" + text3;
				text += "\n";
				result = false;
			}
			message = text;
			return result;
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			this.m_MeasureType = EscalatorForm.MeasureType.MT_None;
			string message = "";
			if (!this.ValidatingDataParam(ref message))
			{
				DialogResult dialogResult = YJKMessageBox.Show(message, MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
				if (DialogResult.Cancel == dialogResult)
				{
					return;
				}
				if (DialogResult.OK == dialogResult)
				{
					base.DialogResult = DialogResult.OK;
					base.Close();
				}
			}
			base.DialogResult = DialogResult.OK;
		}

		private void hyTbGuardHeight_Validating(object sender, CancelEventArgs e)
		{
			if (this.GuardHeight < 900.0 || this.GuardHeight > 1100.0)
			{
				this.hyTbGuardHeight.Text = (string)this.hyTbGuardHeight.Tag;
				MessageBox.Show("栏杆高度：应该>=900mm且<=1100mm", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
			this.SetTextBoxTag(this.hyTbGuardHeight);
		}

		private void hyTbHeight_Validating(object sender, CancelEventArgs e)
		{
			if (this.InclineAngle != 0.0 && this.StairsHeight < 1000.0)
			{
				this.hyTbHeight.Text = (string)this.hyTbHeight.Tag;
				MessageBox.Show("扶梯高度：应该>=1000mm", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
			this.SetTextBoxTag(this.hyTbHeight);
		}

		private void hyTbRunDepth_Validating(object sender, CancelEventArgs e)
		{
			if (this.InclineAngle != 0.0 && (YJKRevitStairs.StairsModel.CommonUnit.Common.IsDoubleLessThanZero(this.TreadDepth) || this.TreadDepth < 380.0))
			{
				this.hyTbRunDepth.Text = (string)this.hyTbRunDepth.Tag;
				MessageBox.Show("梯级深度应该>=380mm", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
			this.SetTextBoxTag(this.hyTbRunDepth);
		}

		private void hyTbFrontDepth_Validating(object sender, CancelEventArgs e)
		{
			if (YJKRevitStairs.StairsModel.CommonUnit.Common.IsDoubleLessThanZero(this.StairsFrontDepth) || this.StairsFrontDepth < 600.0)
			{
				this.hyTbFrontDepth.Text = (string)this.hyTbFrontDepth.Tag;
				MessageBox.Show("前沿进深应该>=600mm", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
			this.SetTextBoxTag(this.hyTbFrontDepth);
		}

		private void hyTbStartDepth_Validating(object sender, CancelEventArgs e)
		{
			if (YJKRevitStairs.StairsModel.CommonUnit.Common.IsDoubleLessThanZero(this.StairsStartDepth) || this.StairsStartDepth < 600.0)
			{
				this.hyTbStartDepth.Text = (string)this.hyTbStartDepth.Tag;
				MessageBox.Show("起步进深应该>=600mm", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
			this.SetTextBoxTag(this.hyTbStartDepth);
		}

		private void hyTbTreadDepth_Validating(object sender, CancelEventArgs e)
		{
			if (YJKRevitStairs.StairsModel.CommonUnit.Common.IsDoubleLessThanZero(this.StairsTreadDepth) || this.StairsTreadDepth < 600.0)
			{
				this.hyTbTreadDepth.Text = (string)this.hyTbTreadDepth.Tag;
				MessageBox.Show("踏板进应该>=600mm", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
			this.SetTextBoxTag(this.hyTbTreadDepth);
		}

		private void hyTbUpPitLength_Validating(object sender, CancelEventArgs e)
		{
			if (YJKRevitStairs.StairsModel.CommonUnit.Common.IsDoubleLessThanZero(this.TopPitLength))
			{
				this.hyTbUpPitLength.Text = (string)this.hyTbUpPitLength.Tag;
				MessageBox.Show("顶部梯坑长度参数不正确", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
			this.SetTextBoxTag(this.hyTbUpPitLength);
		}

		private void hyTbDownPitLength_Validating(object sender, CancelEventArgs e)
		{
			if (YJKRevitStairs.StairsModel.CommonUnit.Common.IsDoubleLessThanZero(this.BtmPitLength))
			{
				this.hyTbDownPitLength.Text = (string)this.hyTbDownPitLength.Tag;
				MessageBox.Show("底部梯坑长度参数不正确", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
			this.SetTextBoxTag(this.hyTbDownPitLength);
		}

		private void hyTbUpPitDepth_Validating(object sender, CancelEventArgs e)
		{
			if (YJKRevitStairs.StairsModel.CommonUnit.Common.IsDoubleLessThanZero(this.TopPitDepth))
			{
				this.hyTbUpPitDepth.Text = (string)this.hyTbUpPitDepth.Tag;
				MessageBox.Show("顶部梯坑深度参数不正确", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
			this.SetTextBoxTag(this.hyTbUpPitDepth);
		}

		private void hyTbDownPitDepth_Validating(object sender, CancelEventArgs e)
		{
			if (YJKRevitStairs.StairsModel.CommonUnit.Common.IsDoubleLessThanZero(this.BtmPitDepth))
			{
				this.hyTbDownPitDepth.Text = (string)this.hyTbDownPitDepth.Tag;
				MessageBox.Show("底部梯坑深度参数不正确", "盈建科提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				e.Cancel = true;
				return;
			}
			this.SetTextBoxTag(this.hyTbDownPitDepth);
		}

		private void label3_Click(object sender, EventArgs e)
		{
		}

		private void label2_Click(object sender, EventArgs e)
		{
		}

		private void label1_Click(object sender, EventArgs e)
		{
		}

		private void hyTbNumSerial_Validating(object sender, CancelEventArgs e)
		{
		}

		private void cmbInclineAngle_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.SetTextBoxTag(this.cmbInclineAngle);
		}

		private void lblRunLength_Click(object sender, EventArgs e)
		{
		}

		private ExternalCommandData m_Revit;

		private Previewer m_MainPreviewer;

		private EscalatorKit m_StairsDrawingKit;

		private int m_BasePointIndex;

		private bool m_bCalc;

		private EscalatorForm.MeasureType m_MeasureType;

		private double m_d10To12 = 600.0;

		private double m_d1To4 = 410.0;

		private double m_d0 = 410.0;

		private double m_dAuto = 400.0;

		private string m_s10To12 = "自动人行道(10-12)";

		private string m_s1To4 = "自动人行道(1-4)";

		private string m_s0 = "自动人行道(0)";

		private string m_sAuto = "自动扶梯";

		public enum MeasureType
		{
			MT_None,
			MT_RunWidth,
			MT_StairsWidth,
			MT_Angle
		}
	}
}
